package dao;

import java.util.Collection;

import model.ArtistBean;
import web.dao.Criteria;
import web.dao.GenericDao;

public class ArtistDao extends GenericDao<ArtistBean> {

	public ArtistDao() {
		super();
	}

	public ArtistBean getArtistById(String id) {
		Collection<ArtistBean> result = findByProperty("id", id);
		if (result.isEmpty()) {
			return null;
		} else {
			return result.iterator().next();
		}
	}

	public ArtistBean getArtistByName(String name) {
		Collection<ArtistBean> result = findByProperty("name", name);
		if (result.isEmpty()) {
			return null;
		} else {
			return result.iterator().next();
		}
	}

	public Collection<ArtistBean> getArtistLikeName(String name) {
		Criteria criteria = Criteria.like("name", "%" + name + "%");
		Collection<ArtistBean> result = findByCriteria(criteria);
		return result;
	}
}
